package com.xl.service.impl;

import com.xl.dao.UserDao;
import com.xl.mapper.SysConfigMapper;
import com.xl.pojo.SysConfig;
import com.xl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


//@Component(value="userService")
@Service(value="userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private SysConfigMapper sysConfigMapper;

    //根据类型进行注入，如果同一类型的bean有多个，尝试根据名字进行二次匹配，匹配不成功再报错
    @Autowired
    @Qualifier("userDao") //在此集合@Autowired一起使用，作用是根据名称进行指定
    @Resource(name = "userDao") //不指定名称参数时，根据类型注入，指定名称就根据名称注入
    private UserDao userDao;

    //@Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Autowired
    public void ddd(List<UserDao> userDaoList) {
        System.out.println("userDao:"+userDaoList);
    }


    @Override
    public void show() {
        //System.out.println(userDao);
        List<SysConfig> list = sysConfigMapper.findAll();
        list.forEach((item)->{
            System.out.println(item.toString());
        });
    }
}
